package com.tianbao54.kotlin_01

fun main(args: Array<String>) {

    var a = 5
    var b = 10

    if (a in 2 .. b) {
        println("a is in the range of 2 to $b")
    }
    // == not in
    if (a !in 2 .. b) {
        println("a is not in the range of 2 to $b")
    }

    println("------------")
    for (i in 2 .. b) {
        println("i = $i")
    }
    println("------------")
    // 与上面的相等
    for (i in 2.rangeTo(10)) {
        println("i = $i")
    }
    println("------------")
    // step 表示一次加多少
    for (i in 2 .. b step 2) {
        println("i = $i")
    }
    println("------------")
    for (i in b downTo 2 step 4) {
        println("downTo i = $i")
    }
}